home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / mxutil / tspak17 / testdiv.asm < prev    next >
Assembly Source File  |  1994-07-25  |  2KB  |  98 lines

  1. ; TESTDIV.ASM
  2. ;
  3. ; This file contains an external assembler subroutine to hook and unhook
  4. ; Int 15h, as well as the replacement handler itself.  For use with
  5. ; Testdiv.pas:
  6. ;
  7. ; {$L TESTDIV}
  8. ; procedure set_i15(
  9. ;   var sounddone:           (* true if sound I/O is complete *)
  10. ;     boolean;
  11. ;   hook:                    (* flag:  0 = hook Int 15h; 1 = unhook Int 15h *)
  12. ;     integer ); external;
  13. ;
  14.  
  15. CODE        SEGMENT    BYTE PUBLIC
  16.         ASSUME    CS:CODE,DS:CODE
  17.         PUBLIC    SET_I15
  18. SET_I15        PROC    NEAR
  19.         JMP    START
  20.         ;
  21.         ; Stack frame.
  22.         ;
  23. STACKFRAME    STRUC    [BP]
  24. OLDBP        DW    ?
  25. RETADDR        DW    ?
  26. HOOK        DW    ?
  27. FLAGPTR        DD    ?
  28.         ENDS
  29.         ;
  30.         ; Local data.
  31.         ;
  32. SOUNDDONE    DD    0    ; pointer to Sounddone flag in main program
  33. INT15OLD    DD    0    ; default vector for Int 15h
  34.         ;
  35.         ; Temporary Int 15h handler.
  36.         ;
  37. INT15NEW:    CMP    AX,91FBh
  38.         JE    >L0
  39.         JMP    DWORD PTR CS:INT15OLD
  40. L0:        PUSH    BX
  41.         PUSH    DS
  42.         LDS    BX,CS:SOUNDDONE
  43.         MOV    BYTE PTR [BX],1
  44.         POP    DS
  45.         POP    BX
  46.         IRET
  47.         ;
  48.         ; Body of the procedure.  DS addresses code segment.
  49.         ;
  50. START:        PUSH    BP
  51.         MOV    BP,SP
  52.         PUSH    DS
  53.         MOV    AX,CS
  54.         MOV    DS,AX
  55.         ;
  56.         ; Check hook/unhook flag.
  57.         ;
  58.         CMP    HOOK,1
  59.         JE    UNHOOK
  60.         ;
  61.         ; We are hooking the interrupt.  Save the default Int 15h
  62.         ; vector.
  63.         ;
  64.         MOV    AX,3515h
  65.         INT    21h
  66.         MOV    WORD PTR INT15OLD,BX
  67.         MOV    WORD PTR INT15OLD+2,ES
  68.         ;
  69.         ; Save the address of the Sounddone flag.
  70.         ;
  71.         LES    BX,FLAGPTR
  72.         MOV    WORD PTR SOUNDDONE,BX
  73.         MOV    WORD PTR SOUNDDONE+2,ES
  74.         ;
  75.         ; Use the new Int 15h handler now.
  76.         ;
  77.         MOV    DX,OFFSET INT15NEW
  78.         MOV    AX,2515h
  79.         INT    21h
  80.         JMP    EXIT
  81.         ;
  82.         ; We are unhooking the interrupt.  Restore the default Int
  83.         ; 15h vector.
  84.         ;
  85. UNHOOK:        MOV    DX,WORD PTR INT15OLD
  86.         MOV    DS,WORD PTR INT15OLD+2
  87.         MOV    AX,2515h
  88.         INT    21h
  89.         ;
  90.         ; Restore DS and BP and exit.
  91.         ;
  92. EXIT:        POP    DS
  93.         POP    BP
  94.         RET    6    ; discard parameters
  95. SET_I15        ENDP
  96. CODE        ENDS
  97.         END
  98.